home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Graphics Plus
/
Graphics Plus.iso
/
general
/
viewers
/
polyview
/
polyvw31.lha
/
Polyview3.1
/
new
/
pv.h
< prev
next >
Wrap
C/C++ Source or Header
|
1993-08-13
|
17KB
|
558 lines
/*****************************************************************************
* NCSA Polyview 3.1 *
* *
* Version 3.1 changes and additions by Gilles Bourhis. *
* Version 3 features and fixes by Marc Andreessen. *
* Version 2 by Brian Calvert. *
* *
* Software Development Group *
* National Center for Supercomputing Applications *
* University of Illinois at Urbana-Champaign *
* *
* Please send bug reports to polyview@ncsa.uiuc.edu. *
* *
* Copyright (c) 1992 The Board of Trustees of the University of Illinois. *
* *
* This NCSA software, both binary and source, is copyrighted, but *
* available without fee for education, academic research and *
* non-commercial purposes. The software is copyrighted in the name of *
* the University of Illinois, and ownership of the software remains with *
* the University of Illinois. Users may distribute the binary and *
* source code to third parties provided that the copyright notice and *
* this statement appears on all copies and that no charge is made for *
* such copies. Any entity wishing to integrate all or part of the *
* source code into a product for commercial use or resale, should *
* contact the University of Illinois, c/o NCSA, to negotiate an *
* appropriate license for such commercial use. *
* *
* THE UNIVERSITY OF ILLINOIS MAKES NO REPRESENTATIONS ABOUT THE *
* SUITABILITY OF THE SOFTWARE FOR ANY PURPOSE. IT IS PROVIDED "AS IS" *
* WITHOUT EXPRESS OR IMPLIED WARRANTY. THE UNIVERSITY OF ILLINOIS SHALL *
* NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY THE USER OF THIS SOFTWARE. *
* The software may have been developed under agreements between the *
* University of Illinois and the Federal Government which entitle the *
* Government to certain rights. *
* *
* By copying this program, you, the user, agree to abide by the *
* copyright conditions and understandings. *
*****************************************************************************/
/* $Id: pv.h,v 1.4 93/08/13 12:56:20 gbourhis Exp $ */
#ifdef RCSLOG
$Log: pv.h,v $
* Revision 1.4 93/08/13 12:56:20 gbourhis
* Add TRANSaddCommand() macro for transcript.
*
* Revision 1.3 93/07/13 16:32:31 gbourhis
* Real PVFREE
*
* Revision 1.2 93/06/24 16:35:28 gbourhis
* new copyright on top of file.
*
* Revision 1.1 1992/09/18 10:55:26 marca
* Initial revision
*
#endif
#ifndef __POLYVIEW_PV_H__
#define __POLYVIEW_PV_H__
/* SYSTEM INCLUDE FILES */
#include <stdio.h>
#include <sys/types.h>
#include <limits.h>
#include <values.h>
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <assert.h>
/* This should only be included if SGI's libmalloc.a is used. */
#ifdef __sgi
#include <malloc.h>
#endif
/* This will include the Xmx, Xm, Xt, and X includes.
Wasteful wasteful wasteful. */
#include "Xmx.h"
#include <Xm/Command.h>
/* GRAPHICS INCLUDE FILES */
#include <gl/gl.h>
/* device.h should never be needed. */
/* #include <gl/device.h> */
/* SGI GL X-related include. */
#ifdef __sgi
#include <gl/glws.h>
#endif
#ifdef _IBMR2
#include "/usr/lpp/GL/utilities/inc/Glib.h"
#endif
/* Include polyview-specific includes. */
#include <df.h>
#include <vg.h>
#include <dtm.h>
#ifdef _IBMR2
#define fhypot hypot
#define facos acos
#define fasin asin
#define fatan2 atan2
#define fcos cos
#define fsin sin
#define ftan tan
#define fexp exp
#define flog log
#endif
/* STATUS CONSTANTS */
#define ST_ERROR 0xdeadbeef
#define ST_OKAY 0xdabadaba
#define ST_EMPTYSTRING 0xffffaaaa
#define X 0
#define Y 1
#define Z 2
#define PHI 0
#define THETA 1
#define RHO 2
#define DIMS 3
#define FROM 0
#define AT 1
#define CARTESIAN 0
#define SPHERICAL 1
#define NONE (0)
#define FOCUSPOINT (1<<0)
#define BOXSHADED (1<<1)
#define BOXWIRE (1<<2)
#define BOXSELECTED (1<<3)
#define AXESSMALL (1<<4)
#define AXESLARGE (1<<5)
#define TOGGLE (1<<6)
#define GRIDXY (1<<7)
#define GRIDXZ (1<<8)
#define GRIDYZ (1<<9)
#define GRIDALL (GRIDXY|GRIDXZ|GRIDYZ)
#define SCATXY (1<<10)
#define SCATXZ (1<<11)
#define SCATYZ (1<<12)
#define SCATALL (SCATXY|SCATXZ|SCATYZ)
#define ALL (~NONE)
#define SIMPLELIGHT 2
#define DEPTHCUE 3
#define PERSPECTIVE 0
#define ORTHOGRAPHIC 1
#define POINTS 0
#define LINES 1
#define POLYGONS 2
/* Window types */
#define STATUS 0
#define PALETTE 1
#define PROBE 2
#define BROWSER 3
#define POLYVIEW 4
#define ISOVIEW 5
#define PIXELVIEW 6
#define VOXELVIEW 7
#define GLYPHVIEW 8
#define DIALOG 9
#define PVSHORT 0
#define PVLONG 1
#define PVINTEGER PVLONG
#define PVFLOAT 2
#define PVCHAR 3
#define PVSTRING PVCHAR
#define PVKEYWORD 4
#define PVDEFAULT 5
#define HDFRIS8 0
#define HDFSDS 1
#define HDFVSET 2
#define UNIX 3
#define DTMPORT 4
#define FILEPATH 0
#define VGROUPPATH 1
#define VDATANAME 2
#define OBJECT (1L<<0)
#define ATOM (1L<<1)
#define INACTIVE (1L<<2)
/* Maxima */
#define MAXLINELEN 1024
#ifdef __sgi
#define MAXPATHLEN 256
#endif
#define MAXNAMELEN 100
#define MAXFORMATLEN 200
#define MAXVDATAS 20 /* Just to be on the safe side. */
#define MAXACTIONARGS 20 /* DITTO */
#define MAXOBJECTS 20 /* DITTO DITTO */
#define MAXDATADIMS 4 /* Maximum width of a vdata. */
/* Constant indexes into the stats records */
#define PX 0 /* X coordinate list */
#define PY 1 /* Y coordinate list */
#define PZ 2 /* Z coordinate list */
#define MCONNECT 3 /* Connectivity master list */
#define MVSCALAR 4 /* Vertex scalar master values */
#define PCOORD 5 /* Composite coordinate array (PX, PY, PZ) */
#define VCOLOR 6 /* Pre-scaled vertex color index */
#define CONNECT 7 /* Active connectivity list */
#define PICKED 8 /* List of picked things (vertices, edges) */
#define UNKNOWN -1
/* Move these kind of constants to static vars within the window create */
#define NTSC_XSIZ 640
#define NTSC_YSIZ 512
#define NTSC_ASPECT NTSC_XSIZ / NTSC_YSIZ
/* Constants for window geometry control. */
#define AUTO 0
#define MANUAL 1
#define PREF 2
#define PREFALL PREF
#define PREFSIZE 4
/* COLOR SUPPORT CONSTANTS AND MACROS */
#define SPEC_BASE 0
#define SPEC_SIZE 256
#define BACKGROUND 0x000000
#define FOREGROUND 0xffffff
#define MAP_COLOR(min,v,max) (1 + (int) SPEC_BASE + (unsigned int) \
( ((v-min)/(max-min))*(SPEC_SIZE-2) + 0.99) )
#define GRAY_INCREMENT (((float) 256) / SPEC_SIZE)
#define R 0
#define G 1
#define B 2
/* Colormap types */
#define PAL_DEFAULT PAL_RAINBOW
#define PAL_RAINBOW 1
#define PAL_W_TO_B 2
#define PAL_B_TO_W 3
#define PAL_RGB 4
#define PAL_ALLYELLOW 5
#define PAL_REDBLUE 6
#define PAL_WHITEBLUE 7
#define PAL_YELLOWRED 8
#define PAL_MAP 32
#define PAL_RESET 64
#define PAL_FILE 128
#define PAL_HDFFILE (PAL_FILE | 0)
#define PAL_RAWFILE (PAL_FILE | 1)
/* gprintf printing commands. */
#define GPR_LEFTJ (1<<0)
#define GPR_CENTERH (1<<1)
#define GPR_RIGHTJ (1<<2)
#define GPR_TOPJ (1<<3)
#define GPR_CENTERV (1<<4)
#define GPR_BOTTOMJ (1<<5)
#define GPR_UNDERL (1<<6)
/* Status window default location and size */
#define STATUS_X 30
#define STATUS_Y 30
#define STATUS_HEIGHT 20
#define STATUS_WIDTH 512
/* MSG_ defines are types of messages. */
#define MSG_NEWACT 0
#define MSG_NEWFRAME 1
#define MSG_VIEWCHG 2
#define MSG_CLOSING 3
#define MSG_RESET 4
#define MSG_NEWDATA 5
#define MSG_NEWPICK 6
#define MSG_REDRAW 7
/* MACROS */
#ifdef __sgi
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#endif
#define ABS(a) (((a) >= 0) ? (a) : (-(a)))
#define SQR(a) ((a) * (a))
#define VALINC(v) (((v) == NULL) ? 0.0 : *((v)++))
#define VALOFF(v,o) (((v) == NULL) ? 0.0 : *(v+o))
#if 1
#define PVMALLOC(s) malloc(s)
#define PVCALLOC(n,t) ((t *)calloc (n, sizeof(t)))
#define PVNEW(t) ((t *)calloc (1, sizeof(t)))
#else /* --- HACK HACK HACK HACK! --- */
#define PVMALLOC(s) malloc(s + s/5)
#define PVCALLOC(n,t) ((t *)calloc (n, sizeof(t) + sizeof(t)/5))
#define PVNEW(t) ((t *)calloc (1, sizeof(t) + sizeof(t)/5))
#endif
#if 1
/* AUUUUUUUUGHGHGHGGH! */
#define PVFREE(p) ( ((p) != NULL) && (free(p), (p) = NULL) )
#else
#define PVFREE(p)
#endif
#define TRANSaddCommand(s,l) \
do if (s->transcript_fp != NULL) { \
fputs(l, s->transcript_fp); \
if (l[strlen(l)-1] != '\n') putc('\n', s->transcript_fp); \
} while (0)
#define FOR_EACH_ACTIVE(w,l) for(w=l->active_windows;w!=NULL;w=NULL)
#define FOR_ALL_WINDOWS(s,w) for(w=s->windows;w!=NULL;w=WIN_NEXT(w))
/* for each frame f which is a member of the window w, do... */
#define FOR_EACH_FRAME(f,i,w) for(f=WIN_FRAMELIST(w),i=WIN_FRAMES(w);\
i>0;f=FRA_NEXT(f),i--)
/* floating-point equality */
#define FEQEPS 0.001
#define FEQABS(x) ((x) < 0.0 ? (-(x)) : (x))
#define FEQ(x,y) (FEQABS(x-y)<FEQEPS ? 1 : 0)
#define DEF_PXNAME "px"
#define DEF_PYNAME "py"
#define DEF_PZNAME "pz"
#define DEF_CONNECTNAME "plist*"
#define DEF_VSCALARNAME "scalar"
#define DEF_VVECTORNAME "vector"
#define DEF_GROUPNAME "/*"
#define WIN_PXNAME(w) (w->vname[PX])
#define WIN_PYNAME(w) (w->vname[PY])
#define WIN_PZNAME(w) (w->vname[PZ])
#define WIN_PLISTNAME(w) (w->vname[MCONNECT])
#define WIN_VSCALARNAME(w) (w->vname[MVSCALAR])
#define WIN_ID(w) (w->id)
#define WIN_NAME(w) (w->name)
#define WIN_TYPE(w) (w->type)
#define WIN_IMAGE(w) (w->image)
#define WIN_POLY(w) ((polyview_t *)WIN_IMAGE(w))
#define WIN_SOURCE(w) (w->source)
#define WIN_SOURCENAME(w) (WIN_SOURCE(w)?WIN_SOURCE(w)->path:"")
#define WIN_GROUPNAME(w) (w->vgroup)
#define WIN_GROUP(w) (w->vgroup_ptr)
#define WIN_INPALETTE(w) (w->inpalette)
#define WIN_OUTPALETTE(w) (w->outpalette)
#define WIN_RASTERNAME(w) (w->rastername)
#define IsRasterContinuous(w) (w->rastercont)
#define IsRasterBlastContinuous(w) (w->rasterblastcont)
#define WIN_RASTERNUM(w) (w->rasternum)
#define WIN_INIT_FN(w) (w->init_fn)
#define WIN_INIT(w) (*WIN_INIT_FN(w))
#define WIN_REDRAW_FN(w) (w->redraw_fn)
#define WIN_REDRAW(w) (*WIN_REDRAW_FN(w))
#define WIN_ANIMATE_FN(w) (w->animate_fn)
#define WIN_ANIMATE(w) (*WIN_ANIMATE_FN(w))
#define WIN_NOTIFY_FN(w) (w->notify_fn)
#define WIN_NOTIFY(w) (*WIN_NOTIFY_FN(w))
#define WIN_EVENT_FN(w) (w->event_fn)
#define WIN_EVENT(w) (*WIN_EVENT_FN(w))
#define WIN_FASTDRAW_FN(w) (w->fastdraw_fn)
#define WIN_FASTDRAW(w) (*WIN_FASTDRAW_FN(w))
#define WIN_DESTROY_FN(w) (w->destroy_fn)
#define WIN_DESTROY(w) (*WIN_DESTROY_FN(w))
#define WIN_PLSREDRAW(w) (w->please_redraw)
#define WIN_ANIMATED(w) (w->animated)
#define WIN_COUNTDOWN(w) (w->countdown)
#define WIN_DELAY(w) (w->speed)
#define WIN_SKIP(w) (w->skip)
#define WIN_LOCKED(w) (w->locked)
#define WIN_FREEZE(w) (w->freeze)
#define WIN_X(w) (w->x)
#define WIN_Y(w) (w->y)
#define WIN_WIDTH(w) (w->width)
#define WIN_HEIGHT(w) (w->height)
#define WIN_CX(w) (w->cx)
#define WIN_CY(w) (w->cy)
#define WIN_BITS(w) (w->bits)
#define WIN_SHADE(w) (w->shade)
#define WIN_OUTLINE_COLOR(w) (w->outline_color)
#define WIN_LIGHT(w) (w->light)
#define WIN_LIGHT_X(w) (w->light_x)
#define WIN_LIGHT_Y(w) (w->light_y)
#define WIN_LIGHT_Z(w) (w->light_z)
#define WIN_LIGHT_TWOSIDE(w) (w->light_twoside)
#define WIN_PALETTE(w) (w->palette)
#define WIN_FRAMES(w) (w->frames)
#define WIN_FRAMEID(w) (w->frame_id)
#define WIN_FRAMELIST(w) (w->frame_list)
#define WIN_FRAME(w) (w->frame)
#define WIN_MAXSELECTED(w) (OBJ_MAXHITS(WIN_ROOTOBJ(w)))
#define WIN_SELECTED(w) (OBJ_HITS(WIN_ROOTOBJ(w)))
#define WIN_STATS(w,v) (w->stats[0][v])
#define WIN_FORWARD(w) (w->forward)
#define WIN_REVERSE(w) (w->reverse)
#define WIN_NEXT(w) (w->next)
#define WinHasData(w) (WIN_FRAMELIST(w)&&WIN_ROOTOBJ(w))
#define WinHasNoData(w) (!WinHasData(w))
#define WIN_ROOTOBJ(w) (FRA_ROOTOBJ(WIN_FRAMELIST(w)))
#define WIN_CURROOTOBJ(w) (FRA_ROOTOBJ(WIN_FRAME(w)))
#define WIN_ROOTOBJINFO(w) (w->info)
#define WIN_DRAW(w) (WIN_ROOTOBJINFO(w)->draw_fn)
#define WIN_SCATDRAW(w) (WIN_ROOTOBJINFO(w)->scatterdraw_fn)
#define WIN_ROT(w) (OIN_ROT(WIN_ROOTOBJINFO(w)))
#define WIN_SCL(w) (OIN_SCL(WIN_ROOTOBJINFO(w)))
#define WIN_TRN(w) (OIN_TRN(WIN_ROOTOBJINFO(w)))
#define FRA_NAME(f) (f->name)
#define FRA_ROOTOBJ(f) (f->object)
#define FRA_PREV(f) (f->prev)
#define FRA_NEXT(f) (f->next)
#define OBJ_TYPE(o) (o->type)
#define OBJ_NAME(o) (o->name)
#define OBJ_INFO(o) (o->info)
#define OBJ_REFS(o) (o->refs)
#define OBJ_STATS(o,v,d) (o->stats[d][v])
#define OBJ_NUMCHILD(o) (o->u.grp.num)
#define OBJ_CHILD(o) (o->u.grp.children)
#define OBJ_SIBLING(o) (o->sibling)
#define OBJ_NUMVERTS(o) (o->u.obj.nvert)
#define OBJ_VDATA(o,v) (o->u.obj.vdata[v])
#define OBJ_HITS(o) (OBJ_INFO(o)->hits)
#define OBJ_MAXHITS(o) (OBJ_INFO(o)->max_hits)
#define OBJ_PICKMODE(o) (OBJ_INFO(o)->pickmode)
#define OBJ_FIRSTID(o) (OBJ_INFO(o)->first_element_id)
#define OBJ_PICKLIST(o) (OBJ_INFO(o)->picked)
#define OBJ_PICKLISTSIZE(o) (OBJ_INFO(o)->size)
#define OIN_REFS(o) (o->refs)
#define OIN_ROT(o) (o->rot)
#define OIN_SCL(o) (o->scl)
#define OIN_TRN(o) (o->trn)
#define OIN_DRAW(o) (*o->draw_fn)
#define XFO_USED(x) (x.used)
#define XFO_COORD(x,c) (x.coord[c])
#define LON_USED(l) (l.used)
#define LON_VALUE(l) (l.value)
#define VDA_ID(v) (v->id)
#define VDA_NAME(v) (v->name)
#define VDA_FILE(v) (v->file)
#define VDA_LOCKED(v) (v->locked)
#define VDA_DATA_IN(v) (v->in_memory)
#define VDA_LASTUSED(v) (v->last_used)
#define VDA_STATS_IN(v) (v->stats_read)
#define VDA_STATS(v) (v->stats[0])
#define VDA_DATA(v,t) ((t *) v->data)
#define VDA_SIBLING(v) (v->sibling)
#define VDA_NEXT(v) (v->next)
#define VGR_NAME(v) (v->name)
#define VGR_ID(v) (v->id)
#define VGR_CHILD_IN(v) (v->children_read)
#define VGR_FILE(v) (v->file)
#define VGR_SIBLING(v) (v->sibling)
#define VGR_GROUPS(v) (v->groups)
#define VGR_VDATAS(v) (v->vdatas)
#define WIN_MOVE(w) (w->move)
#define WIN_PROJECTION(w) (w->projection)
#define WIN_COLORMODE(w) (w->colormode)
#define WIN_AT(w) (w->at)
#define WIN_CFROM(w) (w->cfrom)
#define WIN_SFROM(w) (w->sfrom)
#define WIN_FOV(w) (w->view_angle)
#define WIN_TWIST(w) (w->twist)
#define WIN_STEP(w) (w->step)
#define WIN_MOVEPATH(w) (w->movepath)
#define WIN_MAXWIDTH(w) (w->max_width)
#define POL_PROBE(p) (p->probe)
#define POL_ACTIVES(p) (p->active_window_thread)
#define POL_OVERLAYS(p) (p->overlays)
#define POL_SHADE(p) (p->shademodel)
#define POL_RENDER(p) (p->render)
#define DEF_FOV 450
#define STA_SOURCES(s) (s->files)
#define STA_STATUS(s) (s->status)
#define STA_PALETTE(s) (s->palette_window)
#define STA_ANIMATE(s) (s->animate_window)
#define GetActiveWindow(s) (s->active_windows)
/* pvdata.h includes all typedefs and enums. */
#include "pvdata.h"
/* pvproto.h should be automatically generated from 'make proto'. */
#include "pvproto.h"
/* pvtokens.h defines unique tokens of range [0x0000, 0xffff] to
uniquely identify GUI functions. */
#include "pvtokens.h"
/* Global current state variable used by menu routines. */
/* This is located in pvmain.c and is the only 'global' variable. */
extern state_t *gstate;
/* This routine sets the current unlit RGB drawing color,
given a colorindex entry. The non-colorindex command
corresponding to this one is cpack. */
#define PALETTECPACK(col) c3s(gstate->pal[col])
#ifndef STREQ
#define STREQ(x,y) (strcmp(x,y) == 0)
#endif
#ifdef DEBUG
#define PVD(x) { printf x; fflush (stdout); }
#else
#define PVD(x)
#endif
#define PRT(x) { printf x; fflush (stdout); }
/* Get rid of asserts for production code. */
/* Will this work? */
#if 0
#ifndef DO_ASSERTS
#define assert(x) x;
#endif
#endif
#ifdef DO_AUDIO
#include "aiff.h"
extern int InitSound (void);
extern void PlayAFile (char *);
#define PLAYAFILE(x) \
if (gstate->use_sound) PlayAFile(x)
#else /* not DO_AUDIO */
#define PLAYAFILE(x)
#endif
#endif /* not __POLYVIEW_PV_H__ */